package com.dq.Week1.day02;

import java.util.Random;
import java.util.Scanner;

public class homeWork1Demo {
    public static void main(String[] args) {
        Random random = new Random();
        Scanner scanner = new Scanner(System.in);
        int rand = random.nextInt(8001) + 2000;
        System.out.println(rand);

        for (int i = 5; i > 0; i--) {
            System.out.println("请输入你猜的价格");
            int sell = scanner.nextInt();
            if (sell == rand) {
                System.out.println("恭喜你，获得了此奖品。");
                break;
            } else {
                if (i > 1) {
                    System.out.println("很遗憾您没有猜对，您还有" + (i - 1) + "次机会");
                }
                if (i == 1) {
                    System.out.println("很可惜，你没有获得奖品，竞猜结束");
                }

            }
        }
    }
}
